package controllers;

import java.util.Calendar;

import javax.swing.JOptionPane;

import GUI.MainGUI;
import GUI.PrincipalGUI.PrincipalReports;
import GUI.PrincipalGUI.PrincipalWindow;
import GUI.PrincipalGUI.principalExam;
import GUI.lecturerGUI.LecturerGenerateExamCode;
import GUI.studentGUI.StudentWindow;
import MsgPackage.GetExamsToExtractPack;
import MsgPackage.PrincGetExamsPack;
import ReportHistogram.ReportHistogram;
import client.ChatClient;
import entities.Principal;
import entities.Student;
public class PrincipalController {
final public static int EXIT = 1; // Quit to login menu.
final public static int MAIN = 2; // Return to main Window.
final public static int REPORT = 3; // Open Reports
public static final int QUESTION = 5;
public static final int EXAM = 4;
public static final int GRADE = 0;
private ChatClient client;
private MainGUI mainGUI;
private Principal princ;
private PrincipalWindow principalwin;
private PrincipalReports  principalReportt1;
private	principalExam principalExam;



public PrincipalController(ChatClient client, MainGUI mainframe) {
	this.client = client;
	this.mainGUI = mainframe;
	mainGUI.setSize(MainGUI.setX, MainGUI.setY);
	PrincipalWindow PrincipalGUI = new PrincipalWindow(this);
	mainGUI.setContentPane(PrincipalGUI);

	if (princ == null) {
		princ = new Principal();
		princ.setID(MainGUI.lgnUsr.getUserID());
	}
}


public void handleprincipalGUI(int operation) {
	
	switch (operation) {
	case EXIT:// logout from the system
		princ = null;
		mainGUI.returnToLogin();
		break;

	case MAIN:// back to main
		if (principalwin == null)
			principalwin = new PrincipalWindow(this);
		mainGUI.setContentPane(principalwin);
		break;

	case REPORT:// report window
		if (principalReportt1 == null)
			principalReportt1 = new PrincipalReports(this);
		
		mainGUI.setContentPane(principalReportt1);
		break;

	case EXAM:// exam window

		if (principalExam == null)
			principalExam = new principalExam(this);
		getexams();
		mainGUI.setContentPane(principalReportt1);
		break;

	case GRADE:// logout from the system
		
		
		break;

	}







}



private void getexams() {
	PrincGetExamsPack princExamMsg = new PrincGetExamsPack(princ);
	client.handleMessageFromClientUI(princExamMsg);	
	princExamMsg = (PrincGetExamsPack) client.getMessage();
//	lecturerGenerateExamCodeGUI.addExams(lctrrexmMsg.GetExam());
}


public static void dohistogram(ReportHistogram h) {
	
	
}}

